/******************************************************************************
** @file	WHResultManager.h
** @author  Joel Chuca Condo
**
** @date	Agu 9, 2010
**
** @desc	This class holds all the WHResult possible objects. 
**			
**
******************************************************************************/

#include "WHResultManager.h"

WHResultManager::WHResultManager()
{
    resMap[W_OK] = WHResult(L"W_OK", L"Operation successful", 0);
    resMap[W_FAILURE] = WHResult(L"W_FAILURE", L"Operation failure", -1);
    resMap[W_CON] = WHResult(L"W_CON", L"Connection failure", 100);
    resMap[W_DIR] = WHResult(L"W_DIR", L"FileDirectory operation failure", 200);
    resMap[W_PROC] = WHResult(L"W_PROC", L"Proccess operation failure", 300);
    resMap[W_SHR] = WHResult(L"W_SHR", L"Share operation failure", 400);
    resMap[W_REG] = WHResult(L"W_REG", L"Reg operation failure", 500);
}

WHResultManager *WHResultManager::pinstance = 0;
WHResultManager* WHResultManager::getInstance()
{
    if (!pinstance)
    {
        pinstance = new WHResultManager;
    }

    return pinstance;
}

WHRESULT WHResultManager::getResult(wstring key)
{
    return resMap[key]._value;
}

wstring WHResultManager::getDescription(WHRESULT wr)
{
    map<wstring, WHResult>::iterator it;
    for ( it=resMap.begin() ; it != resMap.end(); it++ )
    {
        if((*it).second._value == wr)
        {
            return (*it).second._description;
        }
    }
    return L"";
}

